/**
  ******************************************************************************
  * @file    BSP_gpio.h
  * @author  Silan - MC Team
  * @version 1.0.0
  * @date    2017/04/26
  * @brief   GPIO Related Config Header File
  * @details None
	* @note    None
  ******************************************************************************
  * @attention
  * THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
  * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
  * AS A RESULT, SILAN MICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
  * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
  * CONTENT OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
  * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
	*
  ******************************************************************************
	* Change History
	* -# 2017/04/26 | v1.0.0 | Wangjianlong | Creat file.
	*
	******************************************************************************
  */

/*******************************************************************************
 * Define to prevent recursive inclusion
 ******************************************************************************/
#ifndef __BSP_GPIO_H__
#define __BSP_GPIO_H__

/*******************************************************************************
 * Includes
 ******************************************************************************/
#include "SC32F58128_Gpio.h"

/*******************************************************************************
 * Typedefs, structs and enums
 ******************************************************************************/

/********************************************************************************
 * Constants and macros
 *******************************************************************************/
#define GPIO_COMPRESS_UP      GPIO_0
#define GPIO_COMPRESS_UN      GPIO_1
#define GPIO_COMPRESS_VP      GPIO_2
#define GPIO_COMPRESS_VN      GPIO_3
#define GPIO_COMPRESS_WP      GPIO_4
#define GPIO_COMPRESS_WN      GPIO_5
#define GPIO_COMPRESS_FAULT   GPIO_33

#define GPIO_FAN_UP           GPIO_6
#define GPIO_FAN_UN           GPIO_7
#define GPIO_FAN_VP           GPIO_8
#define GPIO_FAN_VN           GPIO_9
#define GPIO_FAN_WP           GPIO_10
#define GPIO_FAN_WN           GPIO_11
#define GPIO_FAN_FAULT        GPIO_36

#define GPIO_PFC_PWM          GPIO_19
#define GPIO_PFC_FAULT        GPIO_16
#define GPIO_PFC_CBC          GPIO_17

#define GPIO_ACFAN_RELAY      GPIO_12
#define GPIO_PTC_RELAY        GPIO_26
#define GPIO_FOUR_WAY_RELAY   GPIO_94
#define GPIO_HEAT_RELAY       GPIO_18

#define GPIO_IIC_SCL          GPIO_32
#define GPIO_IIC_SDA          GPIO_24

#define GPIO_WATCHER_TXD      GPIO_29
#define GPIO_WATCHER_RXD      GPIO_28
#define GPIO_SI_TXD           GPIO_31
#define GPIO_SI_RXD           GPIO_30
#define GPIO_PC_TXD           GPIO_22
#define GPIO_PC_RXD           GPIO_23

#define GPIO_MVA              GPIO_21
#define GPIO_MVB              GPIO_20
#define GPIO_MVC              GPIO_34
#define GPIO_MVD              GPIO_60

#define GPIO_LED1             GPIO_38
#define GPIO_LED2             GPIO_37
#define GPIO_LED3             GPIO_35

#define GPIO_FORCE_RUN        GPIO_28

#define GPIO_IU_AD_COMP       GPIO_80
#define GPIO_IVN_AD_FAN       GPIO_81
#define GPIO_IAC_AD           GPIO_82
#define GPIO_AIR_AD           GPIO_83
#define GPIO_DIS_AD           GPIO_84
#define GPIO_COIL_AD          GPIO_86
#define GPIO_SUCK_AD          GPIO_87
#define GPIO_TEMP_COMP        GPIO_88
#define GPIO_VDC_AD           GPIO_89
#define GPIO_IPM_SEL          GPIO_90
#define GPIO_IUN_AD_FAN       GPIO_91
#define GPIO_TEMP_FAN         GPIO_92
#define GPIO_VAC_AD           GPIO_95

#define GPIO_TESTPIN          GPIO_21


#define PTC_RELAY_ON          GPIO_SetHigh(GPIO_PTC_RELAY)
#define PTC_RELAY_OFF         GPIO_SetLow (GPIO_PTC_RELAY)

#define FAN_RELAY_ON          GPIO_SetHigh(GPIO_ACFAN_RELAY)
#define FAN_RELAY_OFF         GPIO_SetLow (GPIO_ACFAN_RELAY)

#define FOUR_WAY_RELAY_ON     GPIO_SetHigh(GPIO_FOUR_WAY_RELAY)
#define FOUR_WAY_RELAY_OFF    GPIO_SetLow (GPIO_FOUR_WAY_RELAY)

#define HEAT_RELAY_ON         GPIO_SetHigh(GPIO_HEAT_RELAY)
#define HEAT_RELAY_OFF        GPIO_SetLow (GPIO_HEAT_RELAY)

#define MVA_HIGH              GPIO_SetHigh (GPIO_MVA)
#define MVA_LOW               GPIO_SetLow  (GPIO_MVA)
#define MVA_TOGGLE            GPIO_Toggle  (GPIO_MVA)
#define MVB_HIGH              GPIO_SetHigh (GPIO_MVB)
#define MVB_LOW               GPIO_SetLow  (GPIO_MVB)
#define MVB_TOGGLE            GPIO_Toggle  (GPIO_MVB)
#define MVC_HIGH              GPIO_SetHigh (GPIO_MVC)
#define MVC_LOW               GPIO_SetLow  (GPIO_MVC)
#define MVC_TOGGLE            GPIO_Toggle  (GPIO_MVC)
#define MVD_HIGH              GPIO_SetHigh (GPIO_MVD)
#define MVD_LOW               GPIO_SetLow  (GPIO_MVD)
#define MVD_TOGGLE            GPIO_Toggle  (GPIO_MVD)

#define LED1_ON               GPIO_SetLow  (GPIO_LED1)
#define LED1_OFF              GPIO_SetHigh (GPIO_LED1)
#define LED1_FLASH            GPIO_Toggle  (GPIO_LED1)
#define LED2_ON               GPIO_SetLow  (GPIO_LED2)
#define LED2_OFF              GPIO_SetHigh (GPIO_LED2)
#define LED2_FLASH            GPIO_Toggle  (GPIO_LED2)
#define LED3_ON               GPIO_SetLow  (GPIO_LED3)
#define LED3_OFF              GPIO_SetHigh (GPIO_LED3)
#define LED3_FLASH            GPIO_Toggle  (GPIO_LED3)

#define SET_SCL_HIGH          GPIO_SetHigh (GPIO_IIC_SCL)
#define SET_SCL_LOW           GPIO_SetLow  (GPIO_IIC_SCL)
#define SET_SCL_TOGGLE        GPIO_Toggle  (GPIO_IIC_SCL)
#define SET_SDA_HIGH          GPIO_SetHigh (GPIO_IIC_SDA)
#define SET_SDA_LOW           GPIO_SetLow  (GPIO_IIC_SDA)
#define SET_SDA_TOGGLE        GPIO_Toggle  (GPIO_IIC_SDA)

#define SET_TESTPIN_HIGH      GPIO_SetHigh (GPIO_TESTPIN)
#define SET_TESTPIN_LOW       GPIO_SetLow  (GPIO_TESTPIN)
#define SET_TESTPIN_TOGGLE    GPIO_Toggle  (GPIO_TESTPIN)

#define GetGpioIntFlg_PFC_FLT()   PB->RIS_b.GPIO0
#define ClrGpioIntFlg_PFC_FLT()   PB->RIS_b.GPIO0 = 1

#define GetGpioIntFlg_COMP_FLT()  PC->RIS_b.GPIO1
#define ClrGpioIntFlg_COMP_FLT()  PC->RIS_b.GPIO1 = 1

#define GetGpioIntFlg_FAN_FLT()   PC->RIS_b.GPIO4
#define ClrGpioIntFlg_FAN_FLT()   PC->RIS_b.GPIO4 = 1

/*******************************************************************************
 * Variables
 ******************************************************************************/


/*******************************************************************************
 * Prototypes of the functions
 ******************************************************************************/
extern void GPIO_GpioInit(void);
extern uint8_t GPIO_gPIOIsHigh(uint8_t IoNumb);

/*---------------------------------- End of the file ---------------------------------*/
#endif /* __BSP_GPIO_H__ */
